const Mitt = {
    state:{

    },
    on(name,callBack){
        if(!this.state[name]){
            this.state[name] = []
        }
        this.state[name].push(callBack)
    },
    emit(name,...arg){
        const array = this.state[name]
        if(!array || !Array.isArray(array)) return
        for(let i = 0; i < array.length; i++ ){
            const fn = array[i]
            fn(...arg)
        }
    }
}


export default Mitt